/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 有点呆
 * Date: 2024-11-07
 * Time: 12:32
 */
import java.util.Scanner;

public class Process {

    private String name;
    private int arriveTime;
    private int serveTime;

    private int index;

    public Process(int i, int arriveTime, int serveTime) {
    }

    public Process(String name, int arriveTime, int serveTime) {
        this.name = name;
        this.arriveTime = arriveTime;
        this.serveTime = serveTime;
    }

    public Process() {

    }

    public boolean isAchieved() {
        if(serveTime <= 0) {
            return true;
        }
        return false;
    }

    public static Process createInitProcess() {//创建初始化进程
        Process process = new Process();
        Scanner sc = new Scanner(System.in);
        process.setName(sc.next());
        System.out.println("请输入进程" + process.getName() + "的到达时间：");
        process.setArriveTime(sc.nextInt());
        System.out.println("请输入进程" + process.getName() + "的服务时间：");
        process.setServeTime(sc.nextInt());
        return process;
    }


    public Process resetServeTime(int timeSlice) {//时间片大小 当一个进程从队列中取出并执行完，期间经过了时间片的处理，服务时间缩减
        this.serveTime = this.serveTime - timeSlice;
        return this;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getArriveTime() {
        return arriveTime;
    }

    public void setArriveTime(int arriveTime) {
        this.arriveTime = arriveTime;
    }

    public int getServeTime() {
        return serveTime;
    }

    public void setServeTime(int serveTime) {
        this.serveTime = serveTime;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public boolean isExecute() {
        return false;
    }
}


